<?php
class Movimientos
{		
	
	public function __construct ()
	{
		
		
	}
	
	/**
	*	Funcion responsable de agregar los ingresos y egresos
	*	@autor: jgCruz
	*	@date: 01/26/2012
	*	@return:
	*/
	
	function addMovimiento($data){
		$sql = "INSERT INTO movimiento (
        `mov_codigo`, 
        `mov_tipo`, 
        `mov_valor`, 
        `mov_nit`, 
        `mov_persona`, 
        `mov_fecha`, 
        `mov_hora`, 
        `mov_descripcion`
		)
		VALUES (
		NULL ,
		'".$data->tipo."',
		'".$data->valor."',
		'".$data->nit."',
		'".$data->nombre."',
		'".date("Y-m-d")."',
		'".date("Y-m-d H:i:s")."',
		'".$data->descripcion."');";
        
        //die($sql);

		return mysql_query ($sql);

	}
	
		
	/**
	*	Esta funcion es la encargada de listar los movimientos contables .
	*	@autor: jgcruz
	*	@parameters: 
	*	@return:
	*/
	function listaMovimientos($search='',$order_by='', $inicio = 0,$cantidad = 0,$desde = '',$hasta = ''){
		$where = '';		
		if($search != '')
		$where = " WHERE (mov_tipo like '%".$search."%'
				   OR mov_nit like '%".$search."%'
				   OR mov_persona like '%".$search."%'
                   OR mov_descripcion like '%".$search."%')";
                   
       if ($desde == '--' && $hasta == '--' || $desde == '' && $hasta == '')
       $desde = $hasta = date('Y/m/d');
       
            if($search != '')    
                $where .= " AND mov_fecha >= '".$desde."'
                          AND mov_fecha <= '".$hasta."'";
            else $where .= "WHERE mov_fecha >= '".$desde."'
                          AND mov_fecha <= '".$hasta."'";
		
		if ($order_by == '')
			$order_by = ' ORDER BY mov_codigo DESC ';
		

		$sql = " SELECT *
                FROM `movimiento`".$where." ".$order_by."";
		

		if ( !($inicio == 0 && $cantidad == 0 ) )
			$sql .= ' LIMIT '.$inicio.', '.$cantidad.';';
            
		//die($sql);
		$consult  = mysql_query($sql);
		$data;
		$i = 0;
		while($row = mysql_fetch_array($consult)){
		  
			$data[$i]->mov_codigo        = $row['mov_codigo'];
			$data[$i]->mov_tipo          = $row['mov_tipo'];
			$data[$i]->mov_valor         = $row['mov_valor'];
			$data[$i]->mov_nit           = $row['mov_nit'];
			$data[$i]->mov_persona       = $row['mov_persona'];
			$data[$i]->mov_fecha         = $row['mov_fecha'];
			$data[$i]->mov_hora          = $row['mov_hora'];	
			$data[$i]->mov_descripcion   = $row['mov_descripcion'];

			$i++;				
		}
		return $data;
	}	


	
	/**
	*	
	*	@autor: jgcruz
	*	Funcion encargada de contar la cantidad de movimientos.
	*	@return:
	*/

	function countMovimientos($search = '', $desde = '',$hasta = ''){	

        $where = '';
        
        if( $search != '')
		$where = " WHERE (mov_tipo like '%".$search."%'
				   OR mov_nit like '%".$search."%'
				   OR mov_persona like '%".$search."%'
                   OR mov_descripcion like '%".$search."%')";
                   
       if ($desde == '--' && $hasta == '--' || $desde == '' && $hasta == '')
       $desde = $hasta = date('Y/m/d');
            
            if($search != '')    
                $where .= " AND mov_fecha >= '".$desde."'
                          AND mov_fecha <= '".$hasta."'";
            else $where .= "WHERE mov_fecha >= '".$desde."'
                          AND mov_fecha <= '".$hasta."'";
       
			
		$sql = "SELECT COUNT(*) as cant FROM movimiento ".$where;
       
		$consulta = mysql_query($sql);
		$row = mysql_fetch_array($consulta);
			
		return $row['cant'];
	}	
			
	
	/**
	*	
	*	@autor: JJR
	*	@date: 01/26/2012
	*	Funcion encargada de contar la cantidad de clientes en la aplicacion.
	*	@return:
	*/
	function countLibranza($search){
		$where = '';		
		if($search != '')
		$where = " WHERE (hdvc_name like '%".$search."%'
				   OR hdv_name like '%".$search."%'
				   OR hdv_lastname like '%".$search."%')";
		
		$sql = "SELECT COUNT(*) AS cant FROM (SELECT t4.lib_code, t4.hdvc_code, t4.hdv_code, t4.lib_total, t4.lib_cuotas_payment, t4.lib_amount_payment, t4.lib_balance , co.hdvc_name FROM
		(SELECT c.lib_code, c.hdvc_code, c.hdv_code, c.lib_total, c.lib_cuotas_payment , c.lib_amount_payment, c.lib_balance
			FROM libranza c WHERE c.lib_status<> 'Deleted'  AND c.lib_balance <> 0) t4 
		LEFT JOIN hdv_company co ON t4.hdvc_code=co.hdvc_code) t5
		LEFT JOIN hdv ho ON t5.hdv_code=ho.hdv_code  ".$where;


		$consulta = mysql_query($sql);
		$row = mysql_fetch_array($consulta);
			
		return $row['cant'];
	}	
	
	/**
	*	
	*	@autor: JJR
	*	@date: 01/26/2012
	*	Funcion encargada de listar los estados.
	*	@return:
	*/
	function companyList()
	{
		$sql = "SELECT hdvc_code, hdvc_name FROM hdv_company";
		$consult = mysql_query($sql);
		$data = array();
		$i = 0;
		while($row = mysql_fetch_array($consult))
		{
			$data[$i]->hdvc_code 		= $row["hdvc_code"];
			$data[$i]->hdvc_name 		= $row["hdvc_name"];	
						
			$i++;
		}			
		return $data;
	}	
	
		function employedList()
	{
		$sql = "SELECT hdv_code, hdv_name, hdv_lastname FROM hdv";
		$consult = mysql_query($sql);
		$data = array();
		$i = 0;
		while($row = mysql_fetch_array($consult))
		{
			$data[$i]->hdv_code 		= $row["hdv_code"];
			$data[$i]->hdv_name 		= $row["hdv_name"];	
			$data[$i]->hdv_lastname 		= $row["hdv_lastname"];	
						
			$i++;
		}			
		return $data;
	}	
	
		function epsList()
	{
		$sql = "SELECT eps_code, eps_name FROM eps";
		$consult = mysql_query($sql);
		$data = array();
		$i = 0;
		while($row = mysql_fetch_array($consult))
		{
			$data[$i]->eps_code 		= $row["eps_code"];
			$data[$i]->eps_name 		= $row["eps_name"];	
						
			$i++;
		}			
		return $data;
	}	
	
		function arpList()
	{
		$sql = "SELECT arp_code, arp_name FROM arp";
		$consult = mysql_query($sql);
		$data = array();
		$i = 0;
		while($row = mysql_fetch_array($consult))
		{
			$data[$i]->arp_code 		= $row["arp_code"];
			$data[$i]->arp_name 		= $row["arp_name"];	
						
			$i++;
		}			
		return $data;
	}
	
		function afpList()
	{
		$sql = "SELECT afp_code, afp_name FROM afp";
		$consult = mysql_query($sql);
		$data = array();
		$i = 0;
		while($row = mysql_fetch_array($consult))
		{
			$data[$i]->afp_code 		= $row["afp_code"];
			$data[$i]->afp_name 		= $row["afp_name"];	
						
			$i++;
		}			
		return $data;
	}
	
		function asesorList()
	{
		$sql = "SELECT ase_code, ase_name FROM asesor";
		$consult = mysql_query($sql);
		$data = array();
		$i = 0;
		while($row = mysql_fetch_array($consult))
		{
			$data[$i]->ase_code 		= $row["ase_code"];
			$data[$i]->ase_name 		= $row["ase_name"];	
						
			$i++;
		}			
		return $data;
	}	
	
		function parafiscalList()
	{
		$sql = "SELECT para_code, para_name, para_porc, para_city FROM parafiscales";
		$consult = mysql_query($sql);
		$data = array();
		$i = 0;
		while($row = mysql_fetch_array($consult))
		{
			$data[$i]->para_code 		= $row["para_code"];
			$data[$i]->para_name 		= $row["para_name"];
			$data[$i]->para_porc 		= $row["para_porc"];
			$data[$i]->para_city 		= $row["para_city"];	
						
			$i++;
		}			
		return $data;
	}	
	
	/**
	*	
	*	@autor: JJR
	*	@date: 01/26/2012
	*	Funcion encargada de listar los users.
	*	@return:
	*/
	function userList()
	{
		$sql = "SELECT use_code, use_name,use_lastname FROM user";
		$consult = mysql_query($sql);
		$data = array();
		$i = 0;
		while($row = mysql_fetch_array($consult))
		{
			$data[$i]->use_code 		= $row["use_code"];
			$data[$i]->use_name 		= $row["use_name"];	
			$data[$i]->use_lastname 	= $row["use_lastname"];
						
			$i++;
		}			
		return $data;
	}	
	
	/**
	*	
	*	@autor: JJR
	*	@date: 01/26/2012
	*	Funcion encargada de listar los Business Types.
	*	@return:
	*/
	function businessTypeList()
	{
		$sql = "SELECT bus_code, bus_name FROM business_type"; 
		$consult = mysql_query($sql);
		$data = array();
		$i = 0;
		while($row = mysql_fetch_array($consult))
		{
			$data[$i]->bus_code 		= $row["bus_code"];
			$data[$i]->bus_name 		= $row["bus_name"];	

			$i++;
		}			
		return $data;
	}	
	
	/**
	*	Funcion responsable de agregar el nombre del business Type.
	*	@autor: JJR
	*	@date: 02/02/2012
	*	@return:
	*/	
	function addBusinessType($data){
		$sql = "INSERT INTO business_type ( bus_code, bus_name) VALUES (NULL, '".$data->bus_name."');";	

		if(mysql_query($sql)){		
			return mysql_insert_id ();
		}else
			return false;
	}	
	
	/**
	*	
	*	@autor: JJR
	*	@date: 01/28/2012
	*	Funcion encargada de listar los case number o Title name del Negocio.
	*	@return:
	*/
	function caseNumberList()
	{
		$sql = "SELECT case_code, case_number FROM my_case"; 
		$consult = mysql_query($sql);
		$data = array();
		$i = 0;
		while($row = mysql_fetch_array($consult))
		{
			$data[$i]->case_code 		= $row["case_code"];
			$data[$i]->case_number 		= $row["case_number"];	

			$i++;
		}			
		return $data;
	}		
	
	/**
	*	
	*	@autor: JJR
	*	@date: 01/26/2012
	*	Funcion encargada de listar los Business Types.
	*	@return:
	*/
	function clientNameList()
	{
		$sql = "SELECT cli_code, cli_name, cli_lastname FROM client"; 
		$consult = mysql_query($sql);
		$data = array();
		$i = 0;
		while($row = mysql_fetch_array($consult))
		{
			$data[$i]->cli_code 		= $row["cli_code"];
			$data[$i]->cli_name 		= $row["cli_name"];	
			$data[$i]->cli_lastname 	= $row["cli_lastname"];	
			$i++;
		}			
		return $data;
	}	
	/**
	*	
	*	@autor: JJR
	*	@date: 01/27/2012
	*	Funcion encargada de obtener los datos de un cliente.
	*	@return:
	*/	
	
	function getLibranzaData($id)
	{
		 $sql = "SELECT t5.lib_code, t5.hdvc_code, t5.hdv_code, t5.lib_value, t5.lib_interes, t5.lib_month, t5.lib_total,t5.lib_cuotas_payment, t5.lib_amount_payment, t5.lib_date_start, t5.lib_date_end, t5.lib_balance, t5.lib_description, t5.hdvc_name , t5.hdvc_nit, he.hdv_name, he.hdv_lastname FROM
		 (SELECT t4.lib_code, t4.hdvc_code, t4.hdv_code, t4.lib_value, t4.lib_interes, t4.lib_month, t4.lib_total, t4.lib_cuotas_payment, t4.lib_amount_payment, t4.lib_date_start, t4.lib_date_end, t4.lib_balance, t4.lib_description ,h.hdvc_name , h.hdvc_nit FROM
		 (SELECT c.lib_code, c.hdvc_code, c.hdv_code, c.lib_value, c.lib_interes, c.lib_month, c.lib_total, c.lib_cuotas_payment, c.lib_amount_payment, c.lib_date_start, c.lib_date_end,c.lib_balance , c.lib_description
		FROM libranza c WHERE c.lib_status<> 'Deleted' AND c.lib_code = ".$id.")t4 LEFT JOIN hdv_company h ON h.hdvc_code=t4.hdvc_code)t5 LEFT JOIN hdv he ON he.hdv_code=t5.hdv_code";
		

		$consult = mysql_query($sql);
		$row = mysql_fetch_array($consult);
		
		$data->lib_code   				= $row['lib_code'] ;
		$data->hdvc_code   				= $row['hdvc_code'] ;
		$data->hdvc_name   				= $row['hdvc_name'] ;
		$data->hdvc_nit   				= $row['hdvc_nit'] ;
		$data->hdv_code   				= $row['hdv_code'] ;
		$data->hdv_name   				= $row['hdv_name'] ;
		$data->hdv_lastname   			= $row['hdv_lastname'] ;
		$data->lib_value   				= $row['lib_value'] ;
		$data->lib_interes  			= $row['lib_interes'] ;
		$data->lib_month 				= $row['lib_month'] ;
		$data->lib_total 				= $row['lib_total'] ;
		$data->lib_cuotas_payment 		= $row['lib_cuotas_payment'] ;
		$data->lib_amount_payment 		= $row['lib_amount_payment'] ;
		$data->lib_date_start  			= $row['lib_date_start'] ;
		$data->lib_date_end  			= $row['lib_date_end'] ;
		$data->lib_balance  			= $row['lib_balance'] ;
		$data->lib_description  		= $row['lib_description'] ;
		
		return $data;	
	}
	

	/**
	*	@autor: JJR
	*	@date: 01/28/2012
	*	Funcion encargada de Actualizar los clientes.
	*	@return:
	*/
	function updateContract($new_data){	
		$sql="UPDATE contract SET 
		cont_type = '".$new_data->cont_type."',
		cont_value = '".$new_data->cont_value."',
		cont_sal_periodo = '".$new_data->cont_sal_periodo."',
		cont_sal_value = '".$new_data->cont_sal_value."',
		cont_cargo = '".$new_data->cont_cargo."',
		cont_day_in = '".$new_data->cont_day_in."',
		cont_day_out = '".$new_data->cont_day_out."',
		cont_funeral = '".$new_data->cont_funeral."',
		cont_admin = '".$new_data->cont_admin."',
		cont_aporte_mutual = '".$new_data->cont_aporte_mutual."',
		eps_code = '".$new_data->eps_code."',
		arp_code = '".$new_data->arp_code."',
		afp_code = '".$new_data->afp_code."',
		cont_name_poliza = '".$new_data->cont_name_poliza."',
		cont_value_poliza = '".$new_data->cont_value_poliza."',
		cont_name_seguro_vida = '".$new_data->cont_name_seguro_vida."',
		cont_value_seguro_vida = '".$new_data->cont_value_seguro_vida."',
		cont_name_otros = '".$new_data->cont_name_otros."',
		cont_value_otros = '".$new_data->cont_value_otros."',
		ase_code = '".$new_data->ase_code."',
		para_code = '".$new_data->para_code."',	
		cont_description = '".$new_data->cont_description."'
		WHERE cont_code =".$new_data->cont_code.";"; 
		
		if(mysql_query($sql)){		
			return true;
		}else
			return false;

	}			
	
	/**
	*	Funcion encargada de Actualizar los datos de un cliente.
	*	@autor: Juan Guillermo Cruz
	*	@date: 01/28/2012
	*	@parameters: 
	*	@return:
	*/	
		function deleteMovimiento($mov_code)
	{
		$sql="DELETE FROM movimiento WHERE `mov_codigo` =".$mov_code;
        //die($sql);
		return mysql_query($sql);
	}

	/**
	*	
	*	@autor: JJR
	*	@date: 01/27/2012
	*	Funcion encargada de obtener los datos de un cliente.
	*	@return:
	*/	
	
	function getBusinessData($case_code)
	{
		 $sql = "SELECT p.case_code, p.case_number, p.pro_comment, p.cli_code, p.bus_code, p.use_code
		FROM my_case p WHERE p.case_code = ".$case_code;
		$consult = mysql_query($sql);
		$row = mysql_fetch_array($consult);
		
		$data->case_code   				= $row['case_code'] ;
		$data->case_number   				= $row['case_number'] ;
		$data->pro_comment   			= $row['pro_comment'] ;
		$data->cli_code   				= $row['cli_code'] ;
		$data->bus_code  				= $row['bus_code'] ;
		$data->use_code 				= $row['use_code'] ;
		
		
		return $data;	
	}	
	
	/**
	*	
	*	@autor: JJR
	*	@date: 01/30/2012
	*	Funcion encargada de Actualizar los Business.
	*	@return:
	*/	
	
		function updateBusiness($new_data){
	
		$sql="UPDATE case SET 
		case_number     = '".$new_data->case_number."',
		pro_comment    = '".$new_data->pro_comment."',
		cli_code    = '".$new_data->cli_code."',
		bus_code    = '".$new_data->bus_code."',
		use_code    = '".$new_data->use_code."'
		WHERE case_code =".$new_data->case_code.";";  
			
		if(mysql_query($sql)){		
			return mysql_insert_id ();
		}else
			return false;
	}	

	/**
	*	Funcion respponsable de agregar un telefono para un cliente;
	*	@autor: JSL
	*	@date: 29/01/2012
	*/
	function addTelephone($data){
		$sql = "INSERT INTO telephone (tel_code, tel_number, tel_ext, tel_type, id_fk) VALUES (NULL, '".$data->tel_number."', '".$data->tel_ext."', 'Employed', '".$data->id_fk."');";
		
		if( mysql_query ($sql) ) 
			return true;	
		else
			return false;
	}
	
	/**
	*	Funcion responsable de listar el/los telefonos de un clientes.
	*	@autor: JSL
	*	@date: 30/01/2012
	*/
	function getTelephones($id_fk){
		$sql = "SELECT t.tel_code, t.tel_number, t.tel_ext FROM telephone t WHERE t.tel_type='Employed' AND t.id_fk=".$id_fk." ORDER BY tel_code;";
		$data = array ();
		if ( $result = mysql_query ($sql) ){
			$i = 0;
			while ( $row = mysql_fetch_array($result) ){
				$data[$i]->tel_code = $row["tel_code"];
				$data[$i]->tel_number = $row["tel_number"];
				$data[$i]->tel_ext = $row["tel_ext"];
				
				$i++;
			}
		}
				
		return $data;
	}
	
	/**
	*	Funcion responsable eliminar los telefonos de un cliente.
	*	@autor: JSL
	*	@date: 30/01/2012
	*/
	function deleteTelephones($id_fk){
		$sql = "DELETE FROM telephone  WHERE tel_type='Employed' AND id_fk=".$id_fk.";";
		return mysql_query ($sql);
	}
	
	/**
	*	Funcion encargada de Actualizar el status de un business a deleted
	*	@autor: JJR
	*	@date: 01/30/2012
	*	@parameters: 
	*	@return:
	*/	
		function deleteBusiness($case_code)
	{
		$sql="UPDATE my_case SET `case_status` =  'Deleted' WHERE `case_code` =".$case_code;
		return mysql_query($sql);
	}
	
	/**
	*	Esta funcion es la encargada de listar los clientes por advisers.
	*	@autor: JJR
	*	@date: 02/09/2012
	*	@parameters: 
	*	@return:
	*/
	function reportClientList($use_code){

		$sql = " SELECT t2.case_code,t2.cli_code,t2.use_code,t2.use_name,t2.use_lastname,t2.cli_name, t2.cli_lastname,t2.cli_address,t2.cli_city,t2.state_code,t2.cli_zip_code,t2.cli_status,st.state_name FROM
		(SELECT t1.case_code,t1.cli_code,t1.use_code,t1.use_name,t1.use_lastname,cl.cli_name, cl.cli_lastname,cl.cli_address,cl.cli_city,cl.state_code,cl.cli_zip_code,cl.cli_status FROM
		(SELECT mc.case_code, mc.cli_code, mc.use_code, u.use_name, u.use_lastname FROM my_case mc LEFT JOIN user u ON u.use_code=mc.use_code)t1 LEFT JOIN client cl ON cl.cli_code = t1.cli_code WHERE cl.cli_status = 'Active')t2 LEFT JOIN state st ON st.state_code=t2.state_code WHERE use_code=".$use_code;
		
		$consult  = mysql_query($sql);
		$data;
		$i = 0;
		while($row = mysql_fetch_array($consult)){
			$data[$i]->cli_code= $row['cli_code'];
			$data[$i]->use_code= $row['use_code'];
			$data[$i]->use_name = $row['use_name'];
			$data[$i]->use_lastname= $row['use_lastname'];
			$data[$i]->cli_name= $row['cli_name'];
			$data[$i]->cli_lastname= $row['cli_lastname'];
			$data[$i]->cli_address= $row['cli_address'];	
			$data[$i]->cli_city= $row['cli_city'];
			$data[$i]->state_code= $row['state_code'];
			$data[$i]->cli_zip_code= $row['cli_zip_code'];
			$data[$i]->state_name= $row['state_name'];
			$data[$i]->telephones = $this->getTelephones((int) $row['cli_code']);

			$i++;				
		}
		return $data;
	}		
	
	/**
	*	Esta funcion es la encargada de listar los loan Numbers de los clientes.
	*	@autor: JJR
	*	@date: 02/13/2012
	*	@parameters: 
	*	@return:
	*/
	function loanNumberList(){

		$sql = " SELECT t0.case_code, t0.loan_number, t0.cli_code, cl.cli_name, cl.cli_lastname FROM
		(SELECT re.case_code,re.loan_number,mc.cli_code FROM request re JOIN my_case mc WHERE re.case_code=mc.case_code)t0 LEFT JOIN client cl ON cl.cli_code=t0.cli_code";
		
		
		$consult  = mysql_query($sql);
		$data;
		$i = 0;
		while($row = mysql_fetch_array($consult)){
			$data[$i]->cli_code= $row['cli_code'];
			$data[$i]->use_code= $row['use_code'];
			$data[$i]->use_name = $row['use_name'];
			$data[$i]->use_lastname= $row['use_lastname'];
			$data[$i]->cli_name= $row['cli_name'];
			$data[$i]->cli_lastname= $row['cli_lastname'];
			$data[$i]->cli_address= $row['cli_address'];	
			$data[$i]->cli_city= $row['cli_city'];
			$data[$i]->state_code= $row['state_code'];
			$data[$i]->cli_zip_code= $row['cli_zip_code'];
			$data[$i]->state_name= $row['state_name'];
			$data[$i]->telephones = $this->getTelephones((int) $row['cli_code']);

			$i++;				
		}
		return $data;
	}		
	

	
		function updateEmployedContratado($data){
	
		$sql="UPDATE hdv SET 
		hdv_contratado     = 'Si'
		WHERE hdv_code =".$data->hdv_code.";";  

		if(mysql_query($sql)){		
			return $data->hdv_code;
		}else
			return false;
	}
	
	// Seleccionamos la compania	
	
	function listCompanySelect($code = '')
	{
		$sql = "SELECT hdvc_code, hdvc_name FROM hdv_company ORDER BY hdvc_name ASC";
		
		$consult  = mysql_query($sql);
		$array = '';
		while($row = mysql_fetch_array($consult))
		{
			if($code == $row['hdvc_code'])
				$array .= '<option value="'.$row['hdvc_code'].'" selected="selected">'.$row['hdvc_name'].'</option>';		
			else
				$array .= '<option value="'.$row['hdvc_code'].'">'.$row['hdvc_name'].'</option>';		
		}
		return $array;	
	}
	
	/////////////////////////////////////////////////////////////////////////////
	// funcion encargada de listar todos los empleados de una compania.
	/////////////////////////////////////////////////////////////////////////////
	function listEmployedSelect($codeCountry = '',$code = '')
	{
		$sql = "SELECT t4.hdvc_code, t4.hdv_code, h.hdv_name , h.hdv_lastname FROM
		(SELECT hdvc_code, hdv_code FROM contract)t4 LEFT JOIN hdv h ON h.hdv_code=t4.hdv_code WHERE t4.hdvc_code =".$codeCountry." ORDER BY h.hdv_name ASC"; 
		$consult  = mysql_query($sql);
		$array = '';
		$array .= '<option value="" disabled selected>Seleccione..</option>';
		while($row = mysql_fetch_array($consult))
		{
			if($code == $row['hdv_code'])
				$array .= '<option value="'.$row['hdv_code'].'" selected>'.$row['hdv_name'].' '.$row['hdv_lastname'].'</option>';		
			else
				$array .= '<option value="'.$row['hdv_code'].'">'.$row['hdv_name'].' '.$row['hdv_lastname'].'</option>';				
		}
		return $array;	
	}	
	


}
?>